import request from '@/utils/request'
import { requestNew } from '@/utils/request'

// 地址列表
export async function getAddress(showLoading = false) {
  const res = await request({
    url: '/bsnl-user-center/province/list?sourceh5',
    custom_baseURL:'VUE_APP_MINI_API',
    method: 'get',
    headers: {
      showLoading
    }
  })
  return res
}
// 用户下级数量统计
export async function getChildStatistic(params, showLoading = false) {
  const res = await request({
    url: '/user/member/get-child-statistic',
    method: 'get',
    params: params || {},
    headers: {
      showLoading
    }
  })
  return res
}
// 我的会员卡详情
export async function getCardDetail(params) {
  const res = await request({
    url: '/user/member/get-card-detail',
    method: 'get',
    params: params || {}
  })
  return res
}
// 我的会员卡历史记录列表
export async function getCardRecords(params, showLoading = true) {
  const res = await request({
    url: '/user/member/get-card-records',
    method: 'get',
    params: params || {},
    headers: {
      showLoading
    }
  })
  return res
}
// 我的好友列表
export async function getFriends(params, showLoading = true) {
  const res = await request({
    url: '/user/member/get-friends',
    method: 'post',
    data: params || {},
    headers: {
      showLoading
    }
  })
  return res
}
// 我的会员卡列表
export async function getMemberCards(params) {
  const res = await request({
    url: '/user/member/get-member-cards',
    method: 'get',
    params: params || {}
  })
  return res
}
// 已到账奖励列表
export async function getObtainedRewards(params) {
  const res = await request({
    url: '/user/member/get-obtained-rewards',
    method: 'get',
    params: params || {}
  })
  return res
}
// 在途奖励列表
export async function getTransitRewards(params) {
  const res = await request({
    url: '/user/member/get-transit-rewards',
    method: 'post',
    data: params || {}
  })
  return res
}
// 会员卡下单
export async function memberCardOrder(params) {
  const res = await request({
    url: '/user/member/member-card/order',
    method: 'post',
    data: params || {}
  })
  return res
}
// 会员卡下单订单编号生成
export async function orderNoGet(params) {
  const res = await request({
    url: '/user/member/member-card/order-no/get',
    method: 'post',
    data: params || {}
  })
  return res
}
// 我的会员奖励
export async function myRewardInfo(params) {
  const res = await request({
    url: '/user/member/my-reward-info',
    method: 'get',
    params: params || {}
  })
  return res
}
// 领取会员卡
export async function receiveCard(params) {
  const res = await request({
    url: '/user/member/receive-card',
    method: 'post',
    data: params || {}
  })
  return res
}
// 发送验证码
export async function sendCode(params) {
  const res = await request({
    url: '/user/member/send-code',
    method: 'get',
    params: params || {}
  })
  return res
}
// 支付页会员卡详细信息
export async function upgradeMemberCardDetail(params) {
  const res = await request({
    url: '/user/member/upgrade-member-card/detail',
    method: 'get',
    params: params || {}
  })
  return res
}
// 我的接口
export async function getMy(params) {
  const res = await request({
    url: '/my',
    method: 'post',
    data: params || {}
  })
  return res
}

// 个人信息接口
export async function getMyInfo(params) {
  const res = await request({
    url: '/my/info',
    method: 'post',
    data: params || {}
  })
  return res
}
// 个人信息更新接口
export async function setMyInfo(params) {
  const res = await request({
    url: '/my/info/edit',
    method: 'post',
    data: params || {}
  })
  return res
}
// 获取短信验证码
export async function sendSms(data = {}) {
  const res = await request({
    url: '/sms/send',
    method: 'post',
    data: {
      region_code: '+86',
      ...data
    }
  })
  return res
}
// 手机号码验证
export async function verifyMobile(data = {}) {
  const res = await request({
    url: '/my/mobile/verify',
    method: 'post',
    data
  })
  return res
}
// 更换手机号码
export async function changeMobile(data = {}) {
  const res = await request({
    url: '/my/mobile/change',
    method: 'post',
    data
  })
  return res
}
// 收货地址列表接口
export async function getShippingAddressList(params) {
  const res = await request({
    url: '/my/shipping-address',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收货地址添加接口
export async function addShippingAddress(params) {
  const res = await request({
    url: '/my/shipping-address/add',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收货地址更新接口
export async function setShippingAddress(params) {
  const res = await request({
    url: '/my/shipping-address/edit',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收货地址智能识别
export async function generateAddress(params) {
  const res = await request({
    url: '/my/shipping-address/match',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收货地址删除接口
export async function deleteShippingAddress(params) {
  const res = await request({
    url: '/my/shipping-address/remove',
    method: 'post',
    data: params || {}
  })
  return res
}
// 绑定邀请码接口
export async function bindInviteCode(params) {
  const res = await request({
    url: '/my/bind-invitecode',
    method: 'post',
    data: params || {}
  })
  return res
}
// 根据邀请码获取信息
export async function getInfoByInviteCode(inviteCode) {
  const res = await request({
    url: '/login/user/invite-code/' + inviteCode,
    method: 'get',
    params: {}
  })
  return res
}
// 我的优惠券接口
export async function getMyCoupon(params) {
  const res = await request({
    url: '/my/coupon',
    method: 'post',
    data: params || {}
  })
  return res
}
// 我的优惠券添加接口
export async function addMyCoupon(params) {
  const res = await request({
    url: '/my/coupon/add',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收藏夹接口
export async function getBookmarks(params) {
  const res = await request({
    url: '/my/bookmarks',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收藏夹添加接口
export async function addBookmarks(params) {
  const res = await request({
    url: '/my/bookmarks/add',
    method: 'post',
    data: params || {}
  })
  return res
}
// 收藏夹添加接口
export async function deleteBookmarks(params) {
  const res = await request({
    url: '/my/bookmarks/remove',
    method: 'post',
    data: params || {}
  })
  return res
}

// 七牛云令牌接口
export async function getQiNiuToken(params) {
  const res = await request({
    url: '/qiniu/upload-token',
    method: 'post',
    data: params || {}
  })
  return res
}

// 获取用户协议：params: { key: '' }
export async function getAgreementDetail(params) {
  const res = await request({
    url: '/get_agreement',
    method: 'get',
    params: params || {}
  })
  return res
}

// 用户协议
export async function userAgreement(params) {
  const res = await request({
    url: '/user-agreement',
    method: 'post',
    data: params || {}
  })
  return res
}

// 隐私协议
export async function userPrivacy(params) {
  const res = await request({
    url: '/user-privacy',
    method: 'post',
    data: params || {}
  })
  return res
}

// 新手指导
export async function guidance(params) {
  const res = await request({
    url: '/guidance',
    method: 'post',
    data: params || {}
  })
  return res
}

// 关于我们
export async function aboutUs(params) {
  const res = await request({
    url: '/about-us',
    method: 'post',
    data: params || {}
  })
  return res
}

// 箱起规则
export async function ruleBox(params) {
  const res = await request({
    url: '/rule/box',
    method: 'post',
    data: params || {}
  })
  return res
}

// 微信帮助
export async function weHelp(params) {
  const res = await request({
    url: '/help/wechat',
    method: 'post',
    data: params || {}
  })
  return res
}
// 新电商法
export async function ruleLaw(params) {
  const res = await request({
    url: '/rule/law',
    method: 'post',
    data: params || {}
  })
  return res
}

// 门店合伙人规则/ 碧选优品协议
export async function storePartnerAgreement(params) {
  const res = await request({
    url: '/store-partner-agreement',
    method: 'post',
    data: params || {}
  })
  return res
}

// 消息中心接口
export async function messageCenter(params) {
  const res = await request({
    url: '/message/center',
    method: 'post',
    data: params || {}
  })
  return res
}

// 渠道消息列表接口
export async function getMessage(params) {
  const res = await request({
    url: '/message',
    method: 'post',
    data: params || {}
  })
  return res
}

// 设置消息已读接口
export async function setMessageRead(params) {
  const res = await request({
    url: '/message/read',
    method: 'post',
    data: params || {}
  })
  return res
}

// 赠品地址接口
export async function getPresentAddress(params) {
  const res = await request({
    url: '/earning/partner/present/address',
    method: 'post',
    data: params || {}
  })
  return res
}

// 赠品地址更新接口
export async function setPresentAddress(params) {
  const res = await request({
    url: '/earning/partner/present/address/edit',
    method: 'post',
    data: params || {}
  })
  return res
}

// 赠品地址更新接口
export async function myInfoLogout(params) {
  const res = await request({
    url: '/my/info/logout',
    method: 'post',
    data: params || {}
  })
  return res
}
// 意见反馈类型接口
export async function feedbackType(params) {
  const res = await requestNew({
    url: '/advice/getAdvice',
    method: 'get',
    params: params || {}
  })
  return res
}
// 意见反馈提交接口
export async function addFeedback(params) {
  const res = await requestNew({
    url: '/advice/addAdvice',
    method: 'post',
    data: params || {}
  })
  return res
}

// 意见反馈提交接口
export async function findUserByInviteCode(params) {
  const res = await requestNew({
    url: '/user',
    method: 'get',
    params: params || {}
  })
  return res
}
// 意见反馈列表接口
export async function feedbackList(params) {
  const res = await requestNew({
    url: '/advice/getAdviceList',
    method: 'post',
    data: params || {}
  })
  return res
}

// 碧选简介
export async function getAboutUs(params) {
  const res = await request({
    url: '/about-us',
    method: 'get',
    params: params || {}
  })
  return res
}

// 碧选直播 帮助中心
export async function getBXZBHelp(type = '') {
  const res = await requestNew({
    url: `/zb-live/system/help/item/${type}`,
    method: 'get'
  })
  return res
}

// 服务协议
export async function getAgreement(params) {
  const res = await request({
    url: '/user-agreement',
    method: 'get',
    params: params || {}
  })
  return res
}

// 平台证照
export async function getCertificates(params) {
  const res = await request({
    url: '/certificates',
    method: 'get',
    params: params || {}
  })
  return res
}

// 隐私政策
export async function getPrivateAgreement(params) {
  const res = await request({
    url: '/private_agreement',
    method: 'get',
    params: params || {}
  })
  return res
}

// 配置中心获取
export async function getConfigCenter(params) {
  const res = await requestNew({
    url: '/message/acm/get',
    method: 'get',
    params: params || {}
  })
  return res
}

// 获取全部退出登录的权限
export async function getLogoutAllFlag(params) {
  const res = await request({
    url: '/my/info/logout/all/verify',
    method: 'get',
    params: params || {},
    headers: {
      showLoading: false
    }
  })
  return res
}

// 获取全部退出登录
export async function logoutAll(params) {
  const res = await request({
    url: '/my/info/logout/all',
    method: 'get',
    params: params || {}
  })
  return res
}
// 提货时用户查看自己的云仓库存列表信息（包含了云仓活动的详细信息）
export async function inventoryList(params) {
  const res = await request({
    url: '/stock/list',
    method: 'get',
    params: params || {}
  })
  return res
}
// 查询用户权限
export async function getPermission(data) {
  const res = await request({
    url: '/stock/user/permission',
    method: 'post',
    data: data || {}
  })
  return res
}
// 查询云仓库存明细
export async function stockDetails(params) {
  const res = await request({
    url: '/stock/combination-stock-detail/list',
    method: 'get',
    params: params || {}
  })
  return res
}
// 查询云仓类型礼包详细列表信息(选择提货商品页)
export async function stockGoods(params) {
  const res = await request({
    url: '/goods/detail/box/list',
    method: 'get',
    params: params || {}
  })
  return res
}
// 查询云仓库存信息
export async function getStockNum(params) {
  const res = await request({
    url: '/stock/query',
    method: 'get',
    params: params || {}
  })
  return res
}
// 获取设置修改交易密码时的验证码
export async function sendVerificationCode(params) {
  const res = await request({
    url: '/my/trade-password/send-verification-code',
    method: 'post',
    data: params || {}
  })
  return res
}
// 交易密码加密公匙
export async function tradePasswordGetPublicKey(params) {
  const res = await request({
    url: '/my/trade-password/get-public-key',
    method: 'post',
    data: params || {}
  })
  return res
}
// 交易密码设置重置
export async function tradePasswordSetUp(params) {
  const res = await request({
    url: '/my/trade-password/set-up',
    method: 'post',
    data: params || {}
  })
  return res
}
